package com.badger.generator;

import static com.badger.generator.constant.DataBaseDriver.BASE_ENTITY;

import java.util.Arrays;
import java.util.List;

import com.badger.generator.constant.DataBaseDriver;
import com.badger.generator.entity.GeneratorAttr;
import com.badger.generator.pattern.AutoGeneratorTemplateFactory;

/**
 * 测试类
 * @author liqi
 *
 */
public class AppTestMysql {

    static List<String> FIELD = Arrays.asList("id", "create_by", "create_name", "create_time", "update_by",
            "update_name", "update_time", "is_deleted");

    public static void main(String[] args) {
        String url = "jdbc:mysql://10.130.16.21:3306/shop";
        String user = "mysqldev";
        String password = "dfzx@mysqldev";
        GeneratorAttr attr = new GeneratorAttr();
        // 作者名字 ;
        attr.setAuthor("liqi");
        // 创建的类的包路径
        attr.setPackagePath("com.dfeps.shop.manage.web.product");
        attr.setDriver(DataBaseDriver.MYSQL);
        attr.setUrl(url);
        attr.setUser(user);
        attr.setPassword(password);
//        attr.setExcludeField(FIELD);
        // 类名需要过滤的开头 eg：T,TB……，默认为null，不过滤表头.
        attr.setIncludePrefix(Arrays.asList("sys", "TB"));
        attr.setTables(Arrays.asList("produtc"));
        // 需要生成的表，默认为null，生成该数据库下，所有的表.
        String path = "D:\\springwind";
        AutoGeneratorTemplateFactory autoFactory = AutoGeneratorTemplateFactory.getInstance(attr);
        autoFactory.buildMpModel(null, true, false);
        autoFactory.buildVoModel(null, true, true);
        autoFactory.buildMapper(DataBaseDriver.MP_MAPPER);
        autoFactory.buildService(DataBaseDriver.MP_SERVICE, DataBaseDriver.MP_SERVICE_IMPL);
        autoFactory.write(path).openFile(path);
    }
}
